import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgentSdVO, AgentSdForm, AgentSdQuery } from '@/api/business/agentSd/types';

/**
 * 查询省代管理列表
 * @param query
 * @returns {*}
 */

export const listAgentSd = (query?: AgentSdQuery): AxiosPromise<AgentSdVO[]> => {
  return request({
    url: '/business/agentSd/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询省代管理详细
 * @param id
 */
export const getAgentSd = (id: string | number): AxiosPromise<AgentSdVO> => {
  return request({
    url: '/business/agentSd/' + id,
    method: 'get'
  });
};

/**
 * 新增省代管理
 * @param data
 */
export const addAgentSd = (data: AgentSdForm) => {
  return request({
    url: '/business/agentSd',
    method: 'post',
    data: data
  });
};

/**
 * 修改省代管理
 * @param data
 */
export const updateAgentSd = (data: AgentSdForm) => {
  return request({
    url: '/business/agentSd',
    method: 'put',
    data: data
  });
};

/**
 * 删除省代管理
 * @param id
 */
// export const delAgentSd = (id: string | number | Array<string | number>) => {
//   return request({
//     url: '/business/agentSd/' + id,
//     method: 'delete'
//   });
// };

/**
 * 用户密码重置
 * @param userId 用户ID
 * @param password 密码
 */
export const resetUserPwd = (userId: string | number, password: string) => {
  const data = {
    userId,
    password
  };
  return request({
    url: '/business/agentSd/resetPwd',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data: data
  });
};
